#include "DifficultyLevel.h"
#include "HelloWorldScene.h"
std::string df[3]=
{
	"chuji","zhongji","gaoji"
};

DifficultyLevel::DifficultyLevel(void)
{
	initDifficultLevel();
}


DifficultyLevel::~DifficultyLevel(void)
{
}

void DifficultyLevel::initDifficultLevel()
{
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	CCSprite *DLBackGround = CCSprite::spriteWithFile(BACKGROUND[3].c_str());
	DLBackGround->setPosition(ccp(size.width/2,size.height/2));
	addChild(DLBackGround);
	CCMenu* pMenu = CCMenu::menuWithItems( NULL);
	pMenu->setPosition(CCPointZero);
	addChild(pMenu);

	for(int i=0;i<3;i++)
	{ 
		CCLabelBMFont* pLabel1=CCLabelBMFont::labelWithString(df[i].c_str(),FONT);
		pLabel1->setScale(0.7f);
		pLabel1->setColor(ccc3(140,250,0));
		CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(pLabel1, this, menu_selector(DifficultyLevel::menuCallback));
		pMenuItem->setPosition(CCPointMake( size.width / 2,size.height/2+120-80*i));
		pMenu->addChild(pMenuItem,i);
	}

}

void DifficultyLevel::menuCallback(CCObject* pSender)
{
	CCMenuItem* pMenuItem = (CCMenuItem *)(pSender);

	CCMenuItemImage *image =(CCMenuItemImage*) pSender;
	image->setColor(ccc3(100,100,100));
	image->setScale(1.1f);
	int nIdx = pMenuItem->getZOrder();
	switch (nIdx)
	{
	case Chuji:
		GamePlaying::difficultylevel=Chuji;
		break;
	case Zhongji:
		 GamePlaying::difficultylevel=Zhongji;
		break;
	case Gaoji:
		GamePlaying::difficultylevel=Gaoji;
		break;
	}
	CCScene *pScene = HelloWorld::scene();
	CCScene *s=  CCTransitionShrinkGrow::transitionWithDuration(1,pScene); 
	  CCDirector::sharedDirector()->replaceScene(s);
}
